<template>
  <div>
    <!-- 头部 -->
    <div class="header">
      <div class="header-up">
        <div class="center">
          <div class="header-left">
            <p>{{ city || '西安' }}</p>
            <span @click="$router.push('/home/position')">切换城市</span>
          </div>
          <div class="header-right">
            <ul>
              <li :class="{active:activ==1}" @click="activ=1,$router.push('/home/index')">首页</li>
              <li :class="{active:activ==2}" @click="activ=2,$router.push('/home/aboutus')">关于我们</li>
              <li :class="{active:activ==3}" @click="activ=3,$router.push('/home/merchant')" >商家入驻</li>
              <li :class="{active:activ==4}" @click="activ=4,$router.push('/home/technician')">技师入住</li>
              <li :class="{active:activ==5}">到位APP</li>
            </ul>
            <span style="cursor: pointer;" @click="$router.push('/login')">商家登录</span>
          </div>
        </div>
      </div> 
      <div class="header-down">
        <div class="center">
          <div class="header-down-center">
            <div class="header-down-left">
              <img class="logo" src="../assets/icon/logo3.png" alt="">
              <p style="color: #666;">高品质上门服务直约平台</p>
            </div>
            <div class="header-down-mid">
              <input type="text" v-model="keyword" placeholder="输入关键词搜索服务商、服务项目">
              <button @click="searchServe(keyword)">搜服务</button>
            </div>
            
            <div class="header-down-right">
              <img src="../assets/icon/daoway1.png" alt="">
              <div class="icon-top" ></div>
              <span>旗下所有APP</span>
            </div>
          </div>
        </div>
      </div>    
    </div>
  </div>
</template>

<script setup lang="ts">
import {ref,reactive} from 'vue'
import httpApi from '@/http'
import { computed } from '@vue/reactivity';
import { useStore } from 'vuex';
import { useRouter } from 'vue-router';

interface City{
  city:[],
  indexes:string
}
const activ = ref(1)
//页脚城市请求
const cities = reactive<City[]>([])
httpApi.cityApi.queryAllcity().then(res =>{
//  console.log(res);
  cities.push(...res.data.data)  
})
// let city = ref()
// city.value = localStorage.getItem('city')
const keyword = ref()
let city = computed(()=>{
  return useStore().state.city
})
const searchServe =  (keyword:string) => {
  const to = useRouter().resolve({
    name:'search-serve',
    query:{
      keyword
    }
  })
  window.open(to.href,'_blank')
}
</script>

<style scoped lang="scss">
.header-up{
  background-color: #CA3544;
  height:50px;
  color: #FFFFFF;
  line-height: 50px;
  font-size: 20px;

  .header-left{
    float: left;
    cursor: pointer;
    p{
      display: inline-block;
      font-weight: 400px;
      padding: 0 15px 0 28px;
      background-image: url(../assets/icon/citypoint2.png);
      background-size: 16px;
      background-repeat: no-repeat;
      background-position: 0 20px;
    }
    span{
      padding: 5px;
      font-size: 12px;
      background-color: #D25360;
      border-radius: 4px;
      &:active{
        opacity: 0.7;
      }
    }
  }
  .header-right{
    float:right;
    display: flex;
    align-items: center;
    ul{
      display: flex;
      font-weight: 400px;
      li{
        padding: 0 20px;
        color: #EFC3C7;
        cursor: pointer;
        &.active{
        color:#FFFFFF;
          &:hover{
            color: #EFC3C7;
            transition: 0.3s;
          }
        }
      
      }
    }
    span{
      display: block;
      font-size: 16px;
      height: 33px;
      line-height: 33px;
      padding: 0 5px;
      background: linear-gradient(to bottom,#FDF7F8,#F1CACE);
      background-color: #fff;
      color: #CA3544;
      font-weight: bold;
      border-radius: 5px;
    }
  }
}
.header-down-center{
  width: 1200px;
  display: flex;
  align-items: center;
  height: 160px;
  .header-down-left{
    font-size: 18px;
    cursor: pointer;
    .logo{
    width:100px;
    margin:0 0 5px 50px;
    }
  }
  .header-down-mid{
    border:2px solid #CA3544;
    border-radius: 5px;  
    margin-left: 80px; 
    input{
      border: none;
      outline:none;
      font-size: 20px;
      width: 420px;
      line-height: 46px;
      padding: 0 55px;
      background-image: url(../assets/icon/searchicon.png);
      background-repeat: no-repeat;
      background-size: 30px;
      background-position: 10px;
    }
	input::placeholder{
		font-size: 14px;
	}
    button{
      border: none;
      line-height: 46px;
      width: 130px;
      color: #fff;
      background-color: #CA3544;
      font-size: 20px;
      cursor: pointer;
    }
  }  
  .header-down-right{
    margin-left: 55px;
    width: 122px;
    background-color: #CA3544;  
    border-radius: 5px;
    position: relative;
    height: 142px;    
    img{
      width: 110px;
      display: block;
      position: absolute;
      border: 1px solid #CCCCCC;
      top: 5px;
      left: 5px;
    } 
    .icon-top{
      border: 8px solid transparent;
      border-bottom-color: #CA3544;
      position: absolute;
      top: -16px;
      left: 56px;
    } 
    span{
      display: block;
      width: 110px;
      color: #fff;
      font-size: 14px;
      position: absolute;
      left: 12px;
      bottom: 4px;
      background-image: url(../assets/icon/sanjiao.png);
      background-repeat: no-repeat;
      background-position: 87px 8px;
    }
  }
}
</style>